﻿<div class="panel panel-default">
<style type="text/css">
  .alert{padding: 5px;float: left;margin-left: 10px;}
</style>
    <div class="panel-heading">
      <h3 class="panel-title">
        筛选商机
        <button class="btn btn-info btn-sm" id="list_btn" data-toggle="modal" data-target="#searchTable">自定义列表项</button>
      </h3>
    </div>
    <div class="panel-body">
      <p class="bg-success alert">成功商机</p>
      <p class="bg-info alert">签约商机</p>
      <p class="bg-danger alert">失败商机</p>
      <!-- 结果表格 -->
      <table class="table table-bordered" id="table_list">
        <thead>
          <tr>
            <th class="row_1" width="78" ng-if="searchTableShow.id==1">商机ID</th>
            <th class="row_2" ng-if="searchTableShow.name==1">客户姓名</th>
            <th class="row_3" ng-if="searchTableShow.school==1">学 校</th>
            <th class="row_4" ng-if="searchTableShow.branch_company==1">分公司</th>
            <th class="row_5" width="100" ng-if="searchTableShow.email==1">邮箱</th>
            <th class="row_6" ng-if="searchTableShow.phone==1">手机</th>
            <th class="row_7" ng-if="searchTableShow.qq==1">QQ</th>
            <th class="row_8" ng-if="searchTableShow.consultant==1">咨询师</th>
            <th class="row_9" ng-if="searchTableShow.channel_manager==1">渠道经理</th>
            <th class="row_10" ng-if="searchTableShow.visit==1">是否上门</th>
            <th class="row_11" ng-if="searchTableShow.positioning==1">是否定位</th>
            <th class="row_12" ng-if="searchTableShow.sign==1">是否签约</th>
            <th class="row_13" ng-if="searchTableShow.sign_out==1">是否退签</th>
            <th class="row_14" ng-if="searchTableShow.order_id==1">订单号</th>
            <th class="row_15" ng-if="searchTableShow.time==1">创建日期</th>
            <th>操作</th>
            <th ng-if="searchTableShow.overdue_num==1">逾期次数</th>
          </tr>
        </thead>
        <tbody>
          <tr class="col" ng-repeat-start="(k,v) in listData track by $index" ng-class="{'bg-info': v.sign==1&&v.business_type==1,'bg-success':v.business_type==5,'bg-danger':v.business_type==4}">
            <td class="row_1" ng-if="searchTableShow.id==1">
              <input type="checkbox" name="id" ng-model='checked[$index]' ng-init="checked[$index]=false">
              <a href="#/Main/main_khxxy/{{v.id}}" target="_black">{{v.id}}
                <!-- <span class="badge">顶</span> -->
                <i class="glyphicon glyphicon-circle-arrow-up text-danger" ng-if="v.stick==1"></i>
              </a>
            </td>
            <td class="row_2" ng-if="searchTableShow.name==1"><a href="#/Main/main_khxxy/{{v.id}}" target="_black">{{v.name}}</a></td>
            <td class="row_3" ng-if="searchTableShow.school==1">{{v.school}}</td>
            <td class="row_4" ng-if="searchTableShow.branch_company==1">{{v.branch_company}}</td>
            <td class="row_5" ng-if="searchTableShow.email==1">{{v.email}}</td>
            <td class="row_6" ng-if="searchTableShow.phone==1">{{v.phone}}</td>
            <td class="row_7" ng-if="searchTableShow.qq==1">{{v.qq}}</td>
            <td class="row_8" ng-if="searchTableShow.consultant==1">{{v.consultant_name}}</td>
            <td class="row_9" ng-if="searchTableShow.channel_manager==1">{{v.channel_manager_name}}</td>
            <td class="row_10" ng-if="searchTableShow.visit==1">
              {{visit==1?"是":"否"}}
            </td>
            <td class="row_11" ng-if="searchTableShow.positioning==1">
              {{positioning==1?"是":"否"}}
            </td>
            <td class="row_12" ng-if="searchTableShow.sign==1">
              {{sign==1?"是":"否"}}
            </td>
            <td class="row_13" ng-if="searchTableShow.sign_out==1">
              {{sign_out==1?"是":"否"}}
            </td>
            <td class="row_14" ng-if="searchTableShow.order_id==1">{{v.order_id}}</td>
            <td class="row_15" ng-if="searchTableShow.time==1">{{v.time}}</td>
            <td><a href="javascript:void(0);" class="btn btn-default btn-sm follow-btn" data-toggle="modal" data-target="#followRecords" ng-click="modalOpen(v.id)">跟进</a></td>
            <td ng-if="searchTableShow.overdue_num==1">{{v.overdue_num}}</td>
          </tr>
          <tr ng-repeat-end>
            <td colspan="17" class="row" ng-if="v.follow_up_records">
              <span class="col-sm-7 col-sm-offset-1 text-left"><label>内容：</label>{{v.follow_up_records[0].follow_records}}</span>
              <span class="col-sm-2"><label>时间：</label>{{v.follow_up_records[0].time}}</span>
              <span class="col-sm-2"><label>联系方式：</label>{{v.follow_up_records[0].communication_mode}}</span>
            </td>
          </tr>
        </tbody>
      </table>
      <button type="button" class="btn btn-primary" ng-click="allSelect()">全选/反选</button>
      <button type="button" class="btn btn-primary" ng-click="stickSubmit()">置顶/取消置顶</button>
    </div>
    <!-- 自定义搜索项模态框 -->
	<div class="modal fade" id="searchTable" tabindex="-1" role="dialog" aria-labelledby="searchTableData" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="searchTableData">自定义搜索项</h4>
				</div>
				<div class="modal-body">
					<ul class="custom_search_list row">
						<li class="col-sm-2"><label><input type="checkbox" value="2" ng-model="searchTableData.id" ng-true-value="1" ng-false-value="0">商机ID</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="3" ng-model="searchTableData.name" ng-true-value="1" ng-false-value="0">客户姓名</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="4" ng-model="searchTableData.school" ng-true-value="1" ng-false-value="0">学校</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="5" ng-model="searchTableData.branch_company" ng-true-value="1" ng-false-value="0">分公司</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="6" ng-model="searchTableData.email" ng-true-value="1" ng-false-value="0">邮箱</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="7" ng-model="searchTableData.phone" ng-true-value="1" ng-false-value="0">手机</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="8" ng-model="searchTableData.qq" ng-true-value="1" ng-false-value="0">QQ</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="9" ng-model="searchTableData.consultant" ng-true-value="1" ng-false-value="0">咨询师</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="10" ng-model="searchTableData.channel_manager" ng-true-value="1" ng-false-value="0">渠道经理</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="11" ng-model="searchTableData.visit" ng-true-value="1" ng-false-value="0">是否上门</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="12" ng-model="searchTableData.positioning" ng-true-value="1" ng-false-value="0">是否定位</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="13" ng-model="searchTableData.sign" ng-true-value="1" ng-false-value="0">是否签约</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="14" ng-model="searchTableData.sign_out" ng-true-value="1" ng-false-value="0">是否退订</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="15" ng-model="searchTableData.order_id" ng-true-value="1" ng-false-value="0">订单号</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="16" ng-model="searchTableData.time" ng-true-value="1" ng-false-value="0">创建日期</label></li>
						<li class="col-sm-2"><label><input type="checkbox" value="17" ng-model="searchTableData.overdue_num" ng-true-value="1" ng-false-value="0">逾期次数</label></li>
					</ul>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary" ng-click="setSearchTable()">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
  <!-- 跟进模态框 -->
  <div class="modal fade bs-example-modal-lg" id="followRecords" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="myModalLabel">跟进</h4>
        </div>
        <form class="form-horizontal search-form" name="follow_records" role="form" ng-submit="addFollowRecords(follow_records.$valid)" novalidate>
          <div class="modal-body">
            <div class="form-group">
              <label class="control-label col-sm-2">沟通方式：</label>
              <div class="col-sm-2">
                <select name="mode" class="form-control" ng-model="followRecords.communication_mode" required>
                  <option value="">请选择</option>
                  <option value="电话">电话</option>
                  <option value="面谈">面谈</option>
                  <option value="QQ">QQ</option>
                  <option value="其他">其他</option>
                  <option value="内部面议">内部面议</option>
                </select>
              </div>
              <label class="control-label col-sm-1">时间：</label>
              <date-input class="col-sm-2" get-date="followRecords.time" style-date="YYYY-MM-DD HH:mm" readonly></date-input>
              <label class="control-label col-sm-1">内容：</label>
              <div class="col-sm-3" ng-class="{'has-error':!follow_records.content.$valid && (!follow_records.$pristine || follow_records.$submitted)}" >
                <input type="text" class="form-control" name="content" ng-model="followRecords.follow_records" required>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="submit" class="btn btn-primary" >添加</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  </div>